import 'dart:ui';

import 'package:flutter/material.dart';

void main() {
  runApp(
    MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: const Text('你好flutter')),
        body: ListView(
          children: const [MyApp()],
        ),
      ),
    ),
  );
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    // TODO flex布局
    return Flex(
      direction: Axis.horizontal,
      children: [
        Expanded(
          flex: 1,
          child: IconContainer(
            Icons.home,
            color: Colors.teal.shade400,
          ),
        ),
        Expanded(
          child: IconContainer(
            Icons.ac_unit_outlined,
            color: Colors.pink.shade400,
          ),
        ),
      ],
    );
  }
}

class IconContainer extends StatelessWidget {
  Color color;
  IconData icon;
  IconContainer(this.icon, {super.key, required this.color});

  @override
  Widget build(BuildContext context) {
    return Container(
      alignment: Alignment.center,
      color: color,
      width: 120,
      height: 120,
      child: Icon(
        icon,
        color: Colors.white,
        size: 50,
      ),
    );
  }
}
